package org.example.gradle.jp.controller;

import gradle.mybatis.common.response.ApiResponse;
import io.swagger.v3.oas.annotations.Operation;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.example.gradle.jp.model.dto.StarWordQueryDto;
import org.example.gradle.jp.model.vo.StarWordVo;
import org.example.gradle.jp.service.StarWordService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 单词 Controller
 *
 * @author 1141193930@qq.com
 */
@Slf4j
@RestController
@RequestMapping("/starWord")
public class StarWordController {

    /**
     * 单词 Service
     */
    @Resource
    private StarWordService starWordService;

    @Operation(summary = "单词列表", method = "POST")
    @PostMapping(value = "/listPage")
    public ApiResponse<List<StarWordVo>> listPage(@RequestBody StarWordQueryDto starWordQueryDto) {
        log.info("starWord - 单词列表");
        return starWordService.listPage(starWordQueryDto);
    }


    @Operation(summary = "分布式事务测试", method = "POST")
    @PostMapping(value = "/seataTransactionalTest")
    public ApiResponse<Boolean> seataTransactionalTest() {
        Boolean b = starWordService.seataTransactionalTest();
        return ApiResponse.success(b);
    }
}
